package com.spring.starter.aspectJ;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @author TW
 */
@Aspect
public class Audience {
//    @Pointcut("execution(* com.spring.starter.aspectJ.Performance.perform(..))")
    public void performance(){}
//    @Before("performance())")
    public void silenceCellPhones(){
        System.out.println("silence cell phones");
    }
//    @Before("performance()")
    public void takeSeats(){
        System.out.println("taking seats");
    }
//    @AfterReturning("performance()")
    public void applause(){
        System.out.println("CLAP CLAP!");
    }
//    @AfterThrowing("performance()")
    public void demandRefund(){
        System.out.println("demanding a refund");
    }
//    @Around("performance()")
    public void watchPerformance(ProceedingJoinPoint jp){
        try {
            System.out.println("silence");
            System.out.println("seat down");
            jp.proceed();
            System.out.println("CLAP");
        } catch (Throwable throwable) {
            System.out.println("refund");
        }
    }
}
